Skip to main content

All Questions

Tagged with
1vote
4answers
748views

Passing arrays as global variables instead of pointers in C

I'm required to write the Low-Level Requirements of a Software Component which shall perform signal processing over arrays of 200k elements of integers/floats which lives in the main memory of the ...
Sam's user avatar
  • 31
0votes
1answer
79views

Avoiding repeating code when assigning pointer addresses based on branch

I have the following code in C that reads data off a char array and makes decisions on what variables should some pointers point to. char preset1[20]; char preset1Name[20]; int preset1Temp; int ...
HFOrangefish's user avatar
0votes
1answer
111views

Is it safe to make training data and labels as global variables in C?

I'm trying to make this function called walk in C. The idea is that the function takes as parameters a point in space (represented by an array), a function (pointer), and a step size / learning rate ...
Mehdi Charife's user avatar
0votes
1answer
402views

Implement Dependency Inversion in C with UML diagram

As per Robert C. Martin in Clean Architecture, he gives a simple UML diagram to illustrate Dependency Inversion. To put it simply, HL1 initially referred to ML1 without interface to invoke F() ...
Andy Lin's user avatar
0votes
1answer
122views

What design pattern (if so) did I apply? How can I further improve it?

Suppose I have a program.c that needs element_123 to do some operations, and element_123 can be accessed by including agent.h /*program.c*/ #include "agent.h" uint32_t element_123 = 0; ...
Andy Lin's user avatar
-2votes
2answers
182views

What is the correct use of -> operator when working with pointers?

I'm pretty new with C so I have encountered many doubts with pointers. I've already search a lot about this but there are some things that still are not clear for me, and I also think this will help ...
Nicolas Bazan's user avatar
5votes
1answer
7kviews

Why do we need to specify the type of data a pointer will hold, if all pointers are the same [duplicate]

Why do we need to specify the type of the data whose address, a pointer will hold, if all pointers are the same. Since all pointers store addresses. Also, the amount of space a pointer will require in ...
amd's user avatar
  • 59
-1votes
1answer
182views

Pointers and Values in C

I do a lot of work in various languages, most of which are scripting languages such as JavaScript, Shell Scripting, PHP and so on. But I do also work a lot with Java, which is closer to a more "real" ...
Daniel B's user avatar
1vote
2answers
315views

Setting a pointer to NULL on failure?

I've been modifying some code written by a previous employee and came across a function with the following signature: BOOL WINAPI PrependPadding( _In_ SIZE_T cbPadding, _In_ SIZE_T cbRow, ...
Govind Parmar's user avatar
26votes
3answers
8kviews

Why does a long int take 12 bytes on some machines?

I noticed something strange after compiling this code on my machine: #include <stdio.h> int main() { printf("Hello, World!\n"); int a,b,c,d; int e,f,g; long int h; ...
yoyo_fun's user avatar
1vote
2answers
2kviews

How to avoid lots of ugly pointer casting when using a container in C?

Let's say I have a container in C, for example something similar to C++' std::deque: struct deque { // blah }; struct deque* deque_create(size_t element_size, size_t init_deq_size); void* ...
gaazkam's user avatar
  • 4,519
4votes
1answer
2kviews

Should opaque pointers be pointers or types?

A common way to implement "PIMPL" in C is to do this: typedef struct _Opaque Opaque; Opaque* createOpaque(); void doSomething(Opaque *opaque); Or: typedef struct _Opaque* Opaque; Opaque ...
user112513312's user avatar
5votes
2answers
4kviews

Type safety - GO vs C pointers

C is a static-typed language that is not type-safe, because pointers(void *y) let you do pretty much anything you like, even things that will crash your program. GO is also a static typed language ...
overexchange's user avatar
2votes
2answers
5kviews

Struct "prototypes" in (plain)C?

As the title says, can it be done? struct Room{ char *type; //Lecture hall, laboratory, etc. char *name; int *capacity; //How may people it can hold struct Building *building; }; ...
Rares Dima's user avatar
9votes
6answers
2kviews

In C, is * an operator, or part of a type in a declaration?

In C, * is called the indirection operator or the dereference operator. I understand how it works when it is used in a statement. It makes sense to write *p or * p, considering that it is a unary ...
Torm's user avatar
  • 151

153050per page
close